import { GSprite } from "../../../../../com/mui/controls/GSprite";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { ObjCreate } from "../../common/ObjCreate";
import { Language } from "../../../../../extend/language/Language";
import { EliteTowerFloorData } from "./EliteTowerFloorData";
import { ResFileConst } from "../../../resource/ResFileConst";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { GModuleEvent } from "../../../mvc/GModuleEvent";
import { DataProvider } from "../../../../../fl/data/DataProvider";
import { Cache } from "../../../cache/Cache";
import { GComboBox } from "../../../../../com/mui/controls/GComboBox";
import { GLoadedButton } from "../../../../../com/mui/controls/GLoadedButton";
type int = number;
//class EliteEnterFloorSp
    
    export  class EliteEnterFloorSp extends GSprite
    {
        constructor()
        {
            super();
            var loc1=GlobalStyle.getTextFormatDefaultFont(GlobalStyle.textFormat1);
            loc1.bold = true;
            var loc2=ObjCreate.createGTextField(Language.getString(60605), 50, 0, 150, 20, this, loc1, false, false);
            this._comBox = ObjCreate.createGComboBox(loc2.x + loc2.textWidth + 5, 0, 100, 25, null, this);
            this._floor0 = new EliteTowerFloorData();
            this._floor0.floor = 0;
            this._floor0.label = Language.getString(60612);
            this._comBox.addEventListener(flash.events.Event.CHANGE, this.onComboxChangeHandler);
            this._comBox.selectedIndex = 0;
            this._enterBtn = ObjCreate.createGLoadedButton(ResFileConst.KingCopyEnterBtn, 93, 30, 97, 42, this);
            this._enterBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onEnterBtnClickHandler);
            this.updateDataProvider();
            ObjCreate.createGTextField(Language.getString(60606), 0, 80, 280, 20, this, GlobalStyle.getTextFormatCenter(GlobalStyle.textFormat6), false, false);
            return;
        }

        /* internal  */onEnterBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.GuildEliteGroup_ShowGroupModule, this._comBox.selectedItem));
            return;
        }

        /* internal  */onComboxChangeHandler(arg1: Object /* flash.events.Event */): void
        {
            this.dispatchEvent(new DataEvent(GModuleEvent.GuildElite_FloorSelectedChange, this._comBox.selectedItem));
            return;
        }

        public set selectedFloor(arg1: int)
        {
            this._comBox.selectedIndex = arg1;
            return;
        }

        public updateDataProvider(): void
        {
            if (!this._enterFloorDp) 
            {
                this._enterFloorDp = new DataProvider();
            }
            this._enterFloorDp.removeAll();
            var loc1=[this._floor0].concat(Cache.instance.guildElite.reachedFloors);
            this._enterFloorDp.addItems(loc1);
            this._comBox.dataProvider = this._enterFloorDp;
            if (Cache.instance.guildElite.inTime || Cache.instance.guildElite.inPreTime) 
            {
                this._enterBtn.enabled = true;
            }
            else 
            {
                this._enterBtn.enabled = false;
            }
            return;
        }

        /* internal */ /* var */_enterFloorDp: DataProvider;

        /* internal */ /* var */_floor0: EliteTowerFloorData;

        /* internal */ /* var */_comBox: GComboBox;

        /* internal */ /* var */_enterBtn: GLoadedButton;
    }
